import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import federation from "@originjs/vite-plugin-federation";
// import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
    plugins: [
        vue(),
        // vueDevTools(),
        federation({
            name: "app1",
            remotes: {
				app2: "http://localhost:3002/assets/remoteEntry.js",
                // format: "var",
                // from: "webpack",
            },
            // 确保依赖共享，避免重复打包
            shared: ["vue"],
        }),
    ],
    build: {
        target: "esnext",
        minify: false, // 可选，关闭压缩以便调试
    },
    resolve: {
        alias: {
            "@": fileURLToPath(new URL("./src", import.meta.url)),
        },
    },
    server: {
        port: 3001,
        open: true,
    },
});
